package com.battery.system.service.battery.impl;

import java.util.List;

import com.battery.common.enums.YesOrNoEnum;
import com.battery.system.service.battery.INoticeService;
import com.battery.system.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.battery.system.mapper.NoticeMapper;
import com.battery.system.domain.Notice;
import com.battery.common.core.text.Convert;
import tk.mybatis.mapper.entity.Example;

/**
 * APP公告Service业务层处理
 *
 * @author battery
 * @date 2021-08-17
 */
@Service
public class NoticeServiceImpl extends BaseServiceImpl<Notice> implements INoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    /**
     * 查询APP公告
     *
     * @param id APP公告ID
     * @return APP公告
     */
    @Override
    public Notice selectNoticeById(String id) {
        return noticeMapper.selectNoticeById(id);
    }

    /**
     * 查询APP公告列表
     *
     * @param notice APP公告
     * @return APP公告
     */
    @Override
    public List<Notice> selectNoticeList(Notice notice) {
        return noticeMapper.selectNoticeList(notice);
    }

    /**
     * 新增APP公告
     *
     * @param notice APP公告
     * @return 结果
     */
    @Override
    public int insertNotice(Notice notice) {
        return noticeMapper.insertNotice(notice);
    }

    /**
     * 修改APP公告
     *
     * @param notice APP公告
     * @return 结果
     */
    @Override
    public int updateNotice(Notice notice) {
        return noticeMapper.updateNotice(notice);
    }

    /**
     * 删除APP公告对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteNoticeByIds(String ids) {
        return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除APP公告信息
     *
     * @param id APP公告ID
     * @return 结果
     */
    @Override
    public int deleteNoticeById(String id) {
        return noticeMapper.deleteNoticeById(id);
    }

    @Override
    public int deleteLogicNoticeByIds(String ids) {
        Notice noticeUpdate = new Notice();
        noticeUpdate.setId(ids);
        noticeUpdate.setIsDelete(YesOrNoEnum.YES.getCode());
        return noticeMapper.updateByPrimaryKeySelective(noticeUpdate);
    }
}
